/***************************************************************************
 * The Open Armory API is a project to retrieve World of Warcraft(R) 
 * related XML data from The Armory.
 * 
 * The data retrieved via the Open Armory API from The Armory is 
 * proprietary to Blizzard Entertainment, Inc(R).
 * *************************************************************************
 * Copyright (C) 2009 - 2010 Tedla M.B. Brandsema
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***************************************************************************/
package net.openarmory.core.domain.constants;

import java.io.IOException;

import net.openarmory.core.config.ConfigurationProperties;

import org.apache.log4j.Logger;

// TODO: Auto-generated Javadoc
/**
 * <p>
 * The Enum <b>ArmoryDataType</b> provides a static reference to The Armory data
 * types.
 * </p>
 * 
 * <p>
 * It also retrieves the filename for a specific Armory data type.
 * </p>
 */
public enum ArmoryDataType implements ArmoryEnum {

	/** The CHARACTER PROFILE. */
	CHARACTER_PROFILE,
	/** The CHARACTER TALENTS. */
	CHARACTER_TALENTS,
	/** The CHARACTER REPUTATION. */
	CHARACTER_REPUTATION,
	/** The CHARACTER ACHIEVEMENTS. */
	CHARACTER_ACHIEVEMENTS,
	/** The CHARACTER STATISTICS. */
	CHARACTER_STATISTICS,
	/** The CHARACTER ARENA. */
	CHARACTER_ARENA,
	/** The CHARACTER ACTIVITY FEED. */
	CHARACTER_ACTIVITY_FEED,
	/** The GUILD ROSTER. */
	GUILD_ROSTER,
	/** The GUILD STATS. */
	GUILD_STATS,
	/** The ITEM. */
	ITEM;

	/** The log. */
	private static final Logger LOG = Logger.getLogger(ArmoryDataType.class);

	/**
	 * Gets the parameter value of the given Armory data type.
	 * 
	 * @return the parameter value
	 */
	@Override
	public String getConsoleParameterValue() {
		switch (this) {
		case CHARACTER_PROFILE:
			return "profile";
		case CHARACTER_TALENTS:
			return "talents";
		case CHARACTER_REPUTATION:
			return "reputation";
		case CHARACTER_ACHIEVEMENTS:
			return "achievements";
		case CHARACTER_STATISTICS:
			return "statistics";
		case CHARACTER_ARENA:
			return "arenateams";
		case CHARACTER_ACTIVITY_FEED:
			return "activityfeed";
		case GUILD_ROSTER:
			return "guildroster";
		case GUILD_STATS:
			return "guildstats";
		case ITEM:
			return "item";
		default:
			return null;
		}
	}

	/**
	 * Gets the string values.
	 * 
	 * @return the string values
	 */
	public static String getStringValues() {
		final StringBuilder concat = new StringBuilder();
		for (final ArmoryDataType armoryDataType : ArmoryDataType.values()) {
			concat.append(armoryDataType.getConsoleParameterValue() + ", ");
		}
		return concat.toString().replaceAll(", $", "");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.openarmory.domain.constants.ArmoryEnum#getUrlConfigProperty()
	 */
	@Override
	public String getUrlConfigProperty() {
		ConfigurationProperties config = null;
		try {
			config = ConfigurationProperties.getInstance();
		} catch (final IOException e) {
			LOG.error("Unable to open configuration.properties file.", e);
		}
		switch (this) {
		case CHARACTER_PROFILE:
			return config.getCharacterProfileFilename();
		case CHARACTER_TALENTS:
			return config.getCharacterTalentsFilename();
		case CHARACTER_REPUTATION:
			return config.getCharacterReputationFilename();
		case CHARACTER_ACHIEVEMENTS:
			return config.getCharacterAchievementsFilename();
		case CHARACTER_STATISTICS:
			return config.getCharacterStatisticsFilename();
		case CHARACTER_ARENA:
			return config.getCharacterArenaFilename();
		case CHARACTER_ACTIVITY_FEED:
			return config.getCharacterActivityFeedFilename();
		case GUILD_ROSTER:
			return config.getGuildRosterFilename();
		case GUILD_STATS:
			return config.getGuildStatsFilename();
		case ITEM:
			return config.getItemTooltipFilename();
		default:
			return null;
		}
	}

}
